//
//  LrcTool.m
//  QQMusic
//
//  Created by wwj on 16/4/25.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "LrcTool.h"
#import "XMGLrcline.h"

@implementation LrcTool

+(NSArray *)lrcsWithName:(NSString *)name{
    NSString *pathStr = [[NSBundle mainBundle] pathForResource:name ofType:nil];
    NSString *lrcStr = [NSString stringWithContentsOfFile:pathStr encoding:NSUTF8StringEncoding error:nil];
    NSArray *lrcArray = [lrcStr componentsSeparatedByString:@"\n"];
    NSMutableArray *dataArray = [NSMutableArray array];
    for (NSString *lrc in lrcArray) {
        if ([lrc hasPrefix:@"[ti"] || [lrc hasPrefix:@"[ar"] || [lrc hasPrefix:@"[al"] || ![lrc hasPrefix:@"["]) {
            continue;
        }
        XMGLrcline *lrcModel = [XMGLrcline lrcLineWithLrclineString:lrc];
        [dataArray addObject:lrcModel];
    }
    return dataArray;
}
@end
